#include <REGX52.H>
#include "Delay.h"
#include "Led_Matrix.h"

//配置定时器
void T0_Init()
{
	TR0=1;
	TMOD&=0xf0;
	TMOD|=0x01;
	TL0=0x66;//1111 1100 0001 1000‬‬
	TH0=0xfc;
	ET0=1;
	EA=1;
	PT0=0;
}

    unsigned int time=0;//定时器计数，每1000次后count++
	unsigned char count=0;//用来移位
	unsigned char i=0;

    unsigned char num[]={
	0,0x7F,0x08,0x08,0x7F,0x00,0x0F,0x15,0x15,   0x0D,0x00,0x7F,0x01,0x00,0x7F,0x01,
	  0x00,0x1E,0x21,0x21,0x1E,0x00,0x7D,0x00,   0x00,0x00,0x00,0x00,0x00,0x00,0x00
	};
	
int main()
{
	T0_Init();

	while(1)
	{
		for(i=1;i<=8;i++)
		{
			LED_Matrix(i,num[i+count]);			
		}
	}
	return 0;
}

void Timer0_Interrupt() interrupt 1
{
	TL0=0x18;//1111 1100 0001 1000‬‬
    TH0=0xfc;
	time++;
	if(time==950)
	{
		count++;
		if(count==22)
		{
			count=0;
		}
		time=0;
	}
}